home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / MosaicSRC / src / TO_HTML.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  4.8 KB  |  167 lines

  1. /* THIS FILE CONTAINS VERSIONS OF THINGS THAT USED TO TALK DIRECTLY TO THE 
  2.    HTML GADGET'S INTERNALS, BUT THAT NOW USE METHODS TO DO THE SAME THING */
  3. #include "includes.h"
  4. #include "htmlgad.h"
  5. #include "globals.h"
  6. #include "HTML.h" /* but try to avoid using it */
  7. #include "mosaic.h"
  8. #include "protos.h"
  9.  
  10. /*
  11.  * Convenience function to set the raw text into the widget.
  12.  * Forces a reparse and a reformat.
  13.  * If any pointer is passed in as NULL that text is unchanged,
  14.  * if a pointer points to an empty string, that text is set to NULL;
  15.  * Also pass an element ID to set the view area to that section of the new
  16.  * text.  Finally pass an anchor NAME to set position of the new text
  17.  * to that anchor.
  18.  */
  19.  
  20. /* THIS IS TOO UGLY... WANT TO IMPLEMEMT IT AS A METHOD WHERE 
  21.    WE SET THE THREE VISIBLE STRINGS, THEN CALL THE METHOD OT FUTZ WITH THE INTERNALS
  22. */
  23. #if FALSE
  24. HERE
  25. void
  26. TO_HTMLSetText(Object *w, char *text, char *header_text, char *footer_text, int element_id, char *target_anchor, WidgetInfo *ptr) /* last param was 
  27. {
  28.   WidgetInfo *wptr = (WidgetInfo *)ptr;
  29.   struct ele_rec *start;
  30.   struct ele_rec *eptr;
  31.   int newy;
  32.   
  33.   if ((text == NULL)&&(header_text == NULL)&&(footer_text == NULL))
  34.     {
  35.       return;
  36.     }
  37.   
  38. }
  39.  
  40. #endif
  41.  
  42. void *TO_HTMLMakeSpaceForElementRef(void){
  43.   return malloc(sizeof (ElementRef));
  44. }
  45.  
  46. extern mo_window window;
  47.  
  48. ULONG TO_HTMLGetScreenDepth(void)
  49. {
  50.     struct Screen *scr;
  51.     get(window.view,MUIA_Window_Screen,&scr);
  52.     if(!scr)
  53.         return 3L;
  54.     else
  55.         return scr->RastPort.BitMap->Depth;
  56. }
  57.  
  58. /*********************************************************************
  59.   NAME: HTML_reset_search() (sb)
  60.  
  61.   PURPOSE: Reset the window search start.
  62. *********************************************************************/
  63. void TO_HTML_reset_search(mo_window *win)
  64. {
  65. /* something like this... */
  66.  if (win->search_start)
  67.   ((ElementRef *)win->search_start)->id = 0;
  68. }
  69.  
  70. void TO_HTML_FlushImageCache(void)
  71. {
  72.     mo_flush_image_cache(&window);
  73.  
  74.     ReformatWindow((HTMLGadClData *)INST_DATA(HTMLGadClass,HTML_Gad));
  75.     ResetAmigaGadgets();
  76.     MUI_Redraw(HTML_Gad,MADF_DRAWOBJECT);
  77. }
  78.  
  79. void TO_HTML_LoadInlinedImage(void)
  80. {
  81.     char *img;
  82.     get(HTML_Gad, HTMLA_image_load, &img);
  83.     LoadInlinedImage(img);
  84. }
  85.  
  86. char **TO_HTMLGetImageSrcs (mo_window *win,int *num)
  87. {
  88.     HTMLGadClData *inst;
  89.     get(HTML_Gad, HTMLA_inst, (ULONG *)(&inst));
  90.     return HTMLGetImageSrcs(inst, num);
  91. }
  92.  
  93. struct mark_up *TO_HTML_GetHTMLObjects(void)
  94. {
  95.     HTMLGadClData *inst=INST_DATA(HTMLGadClass,HTML_Gad);
  96.     return inst->html_objects;
  97. }
  98.  
  99. void TO_HTML_SetSearch(void)
  100. {
  101. #if FALSE /*    above fn HAS TO DO */
  102.         if (str && *str)
  103.           {
  104.             int backward, caseless, rc;
  105.  
  106.         get(win->search_backwards_toggle, MUIA_Selected, &backward);
  107.         get(win->search_caseless_toggle, MUIA_Selected, &caseless);
  108.  
  109.             if (!backward)
  110.               {
  111.                 /* Either win->search_start->id is 0, in which case the search
  112.                    should start from the beginning, or it's non-0, in which case
  113.                    at least one search step has already been taken.
  114.                    If the latter, it should be incremented so as to start
  115.                    the search after the last hit.  Right? */
  116.                 if (((ElementRef *)win->search_start)->id)
  117.                   {
  118.                     ((ElementRef *)win->search_start)->id =
  119.                       ((ElementRef *)win->search_end)->id;
  120.                     ((ElementRef *)win->search_start)->pos =
  121.                       ((ElementRef *)win->search_end)->pos;
  122.                   }
  123.                 
  124.               }
  125.  
  126.             rc = HTMLSearchText 
  127.               (win->scrolled_win, str, 
  128.                (ElementRef *)win->search_start, 
  129.                (ElementRef *)win->search_end, 
  130.                backward, caseless);
  131.  
  132.             if (rc == -1)
  133.               {
  134.                 /* No match was found. */
  135.                 if (((ElementRef *)win->search_start)->id)
  136.             MUI_Request(App, WI_Main, 0,
  137.                     "Amiga Mosaic: Find Result", "*_OK",
  138.                      "Sorry, no more matches in this document.",
  139.                      TAG_END) ;
  140.                 else
  141.             MUI_RequestA(App, WI_Main, 0,
  142.                      "Amiga Mosaic: Find Result", "*_OK",
  143.                      "Sorry, no matches in this document.",
  144.                      TAG_END) ;
  145.               }
  146.             else
  147.               {
  148.                 /* Now search_start and search_end are starting and ending
  149.                    points of the match. */
  150.         HTMLGotoId(win->scrolled_win,
  151.             ((ElementRef *)win->search_start)->id);          
  152. //        ResetAmigaGadgets();
  153.  
  154.                 /* Set the selection. */
  155. #if    0    /* Needs to wait for HTMLSetSelection to work */
  156.                 HTMLSetSelection (win->scrolled_win, (ElementRef *)win->search_start,
  157.                                   (ElementRef *)win->search_end);
  158. #endif
  159.               } /* found a target */
  160.           } /* if str && *str */
  161. #endif
  162. }
  163.  
  164. void ForgetALLHTMLAmigaData(void)
  165. {
  166. }
  167.